{% extends "manage.html" %}
{% load static %}

{% block title %} My Quizzes {% endblock %}
{% block content %}
<div class="container">
    <div class="row">
        <div class="col-md-8">
            <ul class="nav nav-pills" id="course_tabs">
                <li class="nav-item">
                    <a class="nav-link {% if created %}active{% endif %}" href="{% url 'yaksh:courses' %}">
                        My Courses
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="{% url 'yaksh:add_course' %}">
                        Add/Edit Course
                    </a>
                </li>
                <li class="nav-item dropdown hide">
                    <a class="nav-link dropdown-toggle active" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="true">More</a>
                    <div class="dropdown-menu hide" x-placement="bottom-start" style="position: absolute; transform: translate3d(0px, 37px, 0px); top: 0px; left: 0px; will-change: transform;">
                    <a class="dropdown-item active" href="{% url 'yaksh:show_all_quizzes' %}">
                        Add/View Quizzes
                    </a>
                    <a class="dropdown-item" href="{% url 'yaksh:show_all_lessons' %}">
                        Add/View Lessons
                    </a>
                    <a class="dropdown-item" href="{% url 'yaksh:show_all_modules' %}">
                        Add/View Modules
                    </a>
                    <a href="{% url 'grades:grading_systems'%}" class="dropdown-item" >
                        Add/View Grading Systems
                    </a>
                </div>
                </li>
            </ul>
        </div>
    </div>
</div>
<div class="container">
    <hr>
    <a href="{% url 'yaksh:add_quiz' %}" class="btn btn-primary btn-lg">
        <i class="fa fa-plus-circle"></i>&nbsp;Add New Quiz
    </a>
    <a href="{% url 'yaksh:add_exercise' %}" class="btn btn-info btn-lg">
        <i class="fa fa-plus-circle"></i>&nbsp;Add New Exercise
    </a>
    {% if not quizzes %}
        <br><br>
        <div class="alert alert-info">
            <center><h3> No quizzes found</h3></center>
        </div>
    {% else %}
        <hr>
        <form name=frm action="" method="post">
            {% csrf_token %}
            <div class="card">
                <div class="card-header">
                    <h3> Search/Filter Quizzes </h3>
                </div>
                <div class="card-body">
                    <div class="row">
                        <div class="col-md-6">
                            {{ form.search_tags }}
                        </div>
                        <div class="col-md-3">
                            {{ form.search_status }}
                        </div>
                    </div>
                    <br>
                    <button class="btn btn-success" type="submit">Search</button>
                    <a class="btn btn-primary" href="{% url 'yaksh:show_all_quizzes' %}">
                        Clear Search
                    </a>
                </div>
            </div>
        </form>
        <hr>
        <center><h4 class="badge badge-success">{{ quizzes_found }} Quiz(zes) Available</h4></center>

        <table class="table table-bordered table-responsive-sm">
        <tr>
        <th>Sr.No</th>
        <th>Quiz/Exercise</th>
        <th>QuestionPaper</th>
        </tr>
        {% for quiz in quizzes %}
        <tr>
        <td>{{forloop.counter}}</td>
        <td width="30%">
            <div class="row">
                <div class="col-md-7">
                    {% if quiz.is_exercise %}
                        <a href="{% url 'yaksh:edit_exercise' quiz.id %}">
                            {{ quiz.description }}
                        </a>
                    {% else %}
                        <a href="{% url 'yaksh:edit_quiz' quiz.id %}">
                            {{ quiz.description }}
                        </a>
                    {% endif %}
                </div>
                <div class="col-md-5">
                    {% if quiz.active %}
                        <span class="badge badge-success badge-pill">
                            Active
                        </span>
                    {% else %}
                        <span class="badge badge-danger badge-pill">
                            Closed
                        </span>
                    {% endif %}
                </div>
            </div>
        </td>
        <td>
            {% if quiz.questionpaper_set.get %}
                <div class="row">
                    <div class="col-md-7">
                        <a href="{% url 'yaksh:designquestionpaper' quiz.id quiz.questionpaper_set.get.id %}">
                        Question Paper for {{ quiz.description }}</a>
                    </div>
                    <div class="col-md-5">
                        <a href="{% url 'yaksh:preview_questionpaper' quiz.questionpaper_set.get.id %}" class="btn btn-primary active btn-xs" target="_blank">
                            <i class="fa fa-eye"></i>&nbsp;Preview
                        </a>
                    </div>
                </div>
            {% else %}
                <div class="row">
                    <div class="col-md-7">
                        <p>No Question Paper</p>
                    </div>
                    <div class="col-md-5">
                        <a href="{% url 'yaksh:designquestionpaper' quiz.id %}" class="btn btn-success">
                            <i class="fa fa-plus-circle"></i>&nbsp;Add
                        </a>
                    </div>
                </div>
            {% endif %}
        </td>
        {% endfor %} <!-- end for quizzes -->
        </tr>
        </table>
    {% endif %}
</div>
{% endblock %}